package service.product.categoryservice;


import entity.Category;
import entity.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description: 关于商品分类的相关方法
 *
 * @author: Cheng
 *
 * @create: 2022-04-13 13:58
 **/
@Component
public interface CategoryAPI {


    /**
     * 分页 ,查询分类信息  包括模糊查询,条件可以有商品名,分类等级,以及所属分类
     * @param pageNo
     * @param pageSize
     * @param cname
     * @param type
     * @param parentId
     * @return ResponseMessage
     */
    @RequestMapping("selectAll")
    @ResponseBody
    public ResponseMessage selectALl(@RequestParam(value = "pageNo",defaultValue = "1")int pageNo,
                                     @RequestParam(value = "pageSize",defaultValue = "5")int pageSize,
                                     @RequestParam(value = "cname",defaultValue = "")String cname,
                                     @RequestParam(value = "type",defaultValue="0") int type,
                                     @RequestParam(value = "parentId",defaultValue = "")int parentId);


    /**
     * 添加一条商品分类信息
     * @param category
     * @return  ResponseMessage
     */
    @RequestMapping("insertCategoryInfo")
    @ResponseBody
    public ResponseMessage insertCategoryInfo(@RequestBody Category category);



    /**
     * 更新一条商品分类信息
     * @param category
     * @return  ResponseMessage
     */
    @RequestMapping("updateCategoryInfo")
    @ResponseBody
    public ResponseMessage updateCategoryInfo(@RequestBody Category category);




    /**
     *删除单条商品分类
     * @param id
     * @return  ResponseMessage
     */
    @RequestMapping("freezeCategoryInfo")
    @ResponseBody
    public ResponseMessage freezeCategoryInfo(@RequestParam("id") String id);


    /**
     * 查询分类的type等级
     * @return
     */
    @RequestMapping("selectByCategoryType")
    @ResponseBody
    public String selectByCategoryType();


    /**
     * 查询type查询所有分类信息
     * @param type
     * @return
     */
    @RequestMapping("selectInsetPageByType")
    @ResponseBody
    public ResponseMessage selectInsetPageByType(@RequestParam("type") int type);


    /**
     * 通过type查找所有的商品分类信息,排除id的
     * @param type
     * @param id
     * @return ResponseMessage
     */
    @RequestMapping("selectUpdatePageByType")
    @ResponseBody
    public ResponseMessage selectUpdatePageByType(@RequestParam("type")  int type ,@RequestParam("id")String id);


    /**
     * 通过id查询单条数据
     * @param id
     * @return ResponseMessage
     */
    @RequestMapping("selectCategoryById")
    @ResponseBody
    public ResponseMessage selectCategoryById(@RequestParam("id") String id);


    /**
     * 查询cname查询所有分类信息
     * @param cname
     * @return
     */
    @RequestMapping("selectInsetPageByCname")
    @ResponseBody
    public ResponseMessage selectInsetPageByCname(@RequestParam("cname") String cname);
}
